finp$="cart_340_CopperBar_demo.tic_13_tunes_notes.hex"
shell("xxd -r -p "+finp$+" > "+finp$+".bin")

gn$="C-C#D-D#E-F-F#G-G#A-A#B-"

open finp$+".bin" for input as #1
open finp$+".txt" for output as #2
while eof(1)=0
  b0=readbyte(1)
  b1=readbyte(1)
  b2=readbyte(1)

  qv=15-(int(b0/16))
  qn=(b0 mod 16)-4:if qn<0 then:q=0:end if
  'qo=7-(int(b2/32))
  qo=(int(b2/32))
  qi=(b2 mod 32)+((int(b1/128))/4)
  o$="--------"
  o$=mid$(gn$,1+(qn*2),2)+hex$((qo+1) mod 16)+hex$(int(qi/16))+hex$(qi mod 16)+hex$(qv mod 16)+"--"
  o$=ucase$(o$)
  if b0+b1+b2=0 then:o$="--------":end if

  print #2,o$

  wend
close #1
close #2

